﻿using B.S.Data.MES.API.Applications.CangKu.Command;
using B.S.Domain.CangKu;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.CangKu.CommandHandlers
{
    public class GetCuQuCommandHandlers : IRequestHandler<GetCuQuCommand, APIRequst<List<CangKuQU>>>
    {
        private readonly IBaseRepository<CangKuQU> cangRepository;

        public GetCuQuCommandHandlers(IBaseRepository<CangKuQU> CangRepository)
        {
            cangRepository = CangRepository;
        }

        public Task<APIRequst<List<CangKuQU>>> Handle(GetCuQuCommand request, CancellationToken cancellationToken)
        {
            var list = cangRepository.GetAll().ToList();
            return Task.FromResult(new APIRequst<List<CangKuQU>>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString(),
                Data = list
            });

        }
    }
}
